Skip to content

Add Create Match with Name (#77) - #206

Open
greenSwanz wants to merge 1 commit into
heroiclabs:masterfrom
greenSwanz:add-create-match-with-name
Open

Add Create Match with Name (#77)#206
greenSwanz wants to merge 1 commit into
heroiclabs:masterfrom
greenSwanz:add-create-match-with-name

Conversation

@greenSwanz

Copy link
Copy Markdown
Contributor

Closes #77.

Adds the ability to optionally pass a name when creating a match, matching the other Nakama SDKs. Per the documentation, the name is used by the server to generate the match ID, so two clients creating a match with the same name end up in the same match.

Implementation

  • Added an optional name parameter to createMatch / createMatchAsync (and the NRtClientInterface declarations), using std::optional<std::string> to follow the existing listMatches convention.
  • Used std::optional rather than a defaulted empty string so the no-name behaviour is preserved exactly, mutable_match_create() is always called, and set_name only runs when a name is actually provided. Existing callers are unaffected.

Note on the test

The test creates two matches with the same name from a single session and asserts they return the same match ID. If the server behaves differently for a same-session repeat, I'm happy to switch it to a two-session setup like test_rt_matchmaker

Testing

  • Added test_rt_create_match_with_name in test_match.cpp, registered in test_rt_match(). It creates two matches with the same name and asserts they return the same match ID, verifying the name feeds into ID generation.
  • Compiles cleanly on Windows (win-x64, MSVC).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Create Match with Name

1 participant